<template>
  <div class="data-two" ref="two"></div>
</template>

<script>
import { zhuanyeData } from "../network/api/api";
const echarts = require("echarts");
export default {
  name: "DataTwo",
  data() {
    return {
      twoData:{}
    }
  },
  methods: {
    getTwoDate() {
      zhuanyeData().then((res) => {
        console.log(res);
        this.twoData = res.data
        this.echartsTwo();
      });
    },
    echartsTwo() {
      const my_echarts = echarts.init(this.$refs.two);
      let options = {
        title: {
          text: "咨询专业分布",
          left: "center",
        },
        toolbox: {
          feature: {
            saveAsImage: {},
          },
        },
        tooltip: {
          trigger: "item",
        },
        legend: {
          orient: "horizontal",
          bottom: "0px",
          width:"80%",
          left:"center"
        },
        series: [
          {
            name: "Access From",
            type: "pie",
            radius: "60%",
            data: this.twoData.list,
            emphasis: {
              itemStyle: {
                shadowBlur: 10,
                shadowOffsetX: 0,
                shadowColor: "rgba(0, 0, 0, 0.5)",
              },
            },
          },
        ],
      };
      my_echarts.setOption(options);
    },
  },
  mounted() {
    this.getTwoDate();
  },
};
</script>

<style lang="less" scoped>
.data-two{
  width: 100%;
  height: 700px;
  padding-bottom: 300px;
}
</style>